{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": 3
  },
  "orig_nbformat": 2
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "Python Pipelining\n",
    "=================\n",
    "\n",
    "The following code block provides a very basic, rudimentary programatic execution of a very simple pipeline. This boiler plate example \"borrowed\" from Tom Osika's very well put together pipeline demo found at https://github.com/tao558/kwiver_demo"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "# import modules needed for programatic process execution\r\n",
    "from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline\r\n",
    "# define path to pipeline file\r\n",
    "\r\n",
    "ep = embedded_pipeline.EmbeddedPipeline()\r\n",
    "ep.build_pipeline(path_to_pipe_file)\r\n",
    "\r\n",
    "ep.start()\r\n",
    "\r\n",
    "ads_in = adapter_data_set.AdapterDataSet.create()\r\n",
    "ads_in[\"image\"] = im_container\r\n",
    "ep.send(ads_in)\r\n",
    "ep.send_end_of_input()\r\n",
    "\r\n",
    "while True:\r\n",
    "    ads_out = ep.receive()\r\n",
    "\r\n",
    "    if ads_out.is_end_of_data():\r\n",
    "        break\r\n",
    "\r\n",
    "\r\n",
    "import time\r\n",
    "time.sleep(5)\r\n",
    "ep.stop()\r\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "Now that we've demonstrated a basic implementation, we run a more complex pipeline from the python interpreter."
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline\r\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "markdown",
   "source": [
    "Of course, we can also run a pipeline from the command line with Kwiver's runner applet. Kwiver's pipelines allow for the execution of both Python and C++ processes provided that compatible data types are leveraged. "
   ],
   "metadata": {}
  }
 ]
}
